package com.lywz.web.action.food;

import java.util.List;

import com.lywz.biz.common.entity.goodfood.Food;
import com.lywz.biz.common.enums.FoodTypeEnum;
import com.lywz.core.log.LogClerk;
import com.lywz.core.util.Pagination;
import com.lywz.web.struts.GZAbstracterAction;

/**
 * @author qianqi yangbolin
 * @date 2010-4-28
 */

public class ShowFoodAction extends GZAbstracterAction {

    private static final long serialVersionUID = 5209539760364030964L;

    //美食主键id
    private Integer foodId;

    //美食类型
    private Integer foodType;

    //一个单独的美食实例
    private Food oneFood;

    //分頁用的分頁類對象
    private Pagination page;

    private int currentPage;

    /**
     * @return the currentPage
     */
    public int getCurrentPage() {
        return currentPage;
    }

    /**
     * @param currentPage the currentPage to set
     */
    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    /**
     * @return the page
     */
    public Pagination getPage() {
        return page;
    }

    /**
     * @param page the page to set
     */
    public void setPage(Pagination page) {
        this.page = page;
    }

    //特色菜肴黔菜list
    private List<Food> specialType1List;

    //特色菜肴汤菜list
    private List<Food> specialType2List;

    //特色菜肴火锅list
    private List<Food> specialType3List;

    //特色菜肴面食list
    private List<Food> specialType4List;

    //特色菜肴糕点list
    private List<Food> specialType5List;

    //一类美食实例序列
    private List<Food> foodList;

    //首页的特色美食列表
    private List<Food> specialFoodList;

    //首页的小吃列表
    private List<Food> xiaochiList;

    //首页的美酒和香茶列表
    private List<Food> drinkAndTeaList;

    //首页的美酒和香茶列表
    private List<Food> techanList;

    //小吃或者特产种类的简单描述
    private String snackOrTechanTpyeDesc;

    //小吃和特产页用的图片列表
    private List<Food> snakeOrTechanImageList;

    //小吃和特产页用的产品列表
    private List<Food> snakeOrTechanList;

    //美酒香茶页用的美酒图片列表
    private List<Food> drinkImageList;

    //美酒香茶页用的香茶图片列表
    private List<Food> teaImageList;

    //美酒香茶页用的美酒列表
    private List<Food> drinkList;

    //美酒香茶页用的香茶列表
    private List<Food> teaList;

    //香茶描述
    private String teaDesc;

    //美酒描述
    private String drinkDesc;

    //all get method

    public String getTeaDesc() {
        return teaDesc;
    }

    public String getDrinkDesc() {
        return drinkDesc;
    }

    public List<Food> getDrinkImageList() {
        return drinkImageList;
    }

    public List<Food> getTeaImageList() {
        return teaImageList;
    }

    public List<Food> getDrinkList() {
        return drinkList;
    }

    public List<Food> getTeaList() {
        return teaList;
    }

    public String getSnackOrTechanTpyeDesc() {
        return snackOrTechanTpyeDesc;
    }

    public List<Food> getSnakeOrTechanImageList() {
        return snakeOrTechanImageList;
    }

    public List<Food> getSnakeOrTechanList() {
        return snakeOrTechanList;
    }

    public List<Food> getSpecialFoodList() {
        return specialFoodList;
    }

    public List<Food> getXiaochiList() {
        return xiaochiList;
    }

    public List<Food> getDrinkAndTeaList() {
        return drinkAndTeaList;
    }

    public List<Food> getTechanList() {
        return techanList;
    }

    public Integer getFoodType() {
        return foodType;
    }

    public List<Food> getFoodList() {
        return foodList;
    }

    public Integer getFoodId() {
        return foodId;
    }

    public Food getOneFood() {
        return oneFood;
    }

    public List<Food> getSpecialType1List() {
        return specialType1List;
    }

    public List<Food> getSpecialType2List() {
        return specialType2List;
    }

    public List<Food> getSpecialType3List() {
        return specialType3List;
    }

    public List<Food> getSpecialType4List() {
        return specialType4List;
    }

    public List<Food> getSpecialType5List() {
        return specialType5List;
    }

    //end of get method

    //all set method
    public void setFoodId(Integer foodId) {
        this.foodId = foodId;
    }

    public void setFoodType(Integer foodType) {
        this.foodType = foodType;
    }

    //end of set method

    /**
     * 点击一个美食，返回该美食具体信息
     * 
     * @return
     */
    public String getFoodDetail() {
        try {
            oneFood = foodService.getOneFood(foodId);
            if (null != oneFood) {
                return SUCCESS;
            } else {
                return ERROR;
            }

        } catch (Exception e) {
            e.printStackTrace();
            return ERROR;
        }
    }

    /**
     * 点击一类美食，返回该类美食所有事务列表
     * 
     * @return
     */
    public String getDetailFoodList() {
        try {
            page = new Pagination(10, 2);
            page.setCurrentPage(currentPage);
            foodList = foodService.getDetailFoodListByFoodType(foodType, page.getCurrentPage(),
                    page.getPageSize());
            return SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ERROR;
        }
    }

    public String getSpecialFoodTypeList() {
        try {
            specialType1List = foodService.getTypedFoodTypeList(FoodTypeEnum.qiancai.getId(), 4);
            specialType2List = foodService.getTypedFoodTypeList(FoodTypeEnum.tangcai.getId(), 4);
            specialType3List = foodService.getTypedFoodTypeList(FoodTypeEnum.huoguo.getId(), 4);
            specialType4List = foodService.getTypedFoodTypeList(FoodTypeEnum.mianshi.getId(), 4);
            specialType5List = foodService.getTypedFoodTypeList(FoodTypeEnum.gaodian.getId(), 4);
            return SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ERROR;
        }
    }

    public String getAllTypeFoodList() {
        try {
            specialFoodList = foodService.getTopSpecialFoodList(4);
            xiaochiList = foodService.getOtherFoodTypeList(FoodTypeEnum.xiaochi.getId(), 2);
            drinkAndTeaList = foodService.getOtherFoodTypeList(FoodTypeEnum.meijiu.getId(), 3);
            drinkAndTeaList.addAll(foodService.getOtherFoodTypeList(FoodTypeEnum.tea.getId(), 2));
            techanList = foodService.getOtherFoodTypeList(FoodTypeEnum.techan.getId(), 4);
            return SUCCESS;
        } catch (Exception e) {
            LogClerk.sysout.info(e);
            return ERROR;
        }
    }

    /**
     * 跳转到特色小吃页面
     * 
     * @return
     */
    public String getSnackeOrTechanPage() {
        try {
            snackOrTechanTpyeDesc = foodTypeService.getFoodTypeDescById(foodType);
            snakeOrTechanImageList = foodService.getTypedFoodTypeList(foodType, 6);
            //TODO　完全不需要分页的一个列表 fuck
            snakeOrTechanList = foodService.getDetailFoodListByFoodType(foodType, 1, 200);
            return isSnackTypeDescNull();
        } catch (Exception e) {
            LogClerk.sysout.error(e);
            return ERROR;
        }
    }

    /**
     * 判断小吃简介是否为空
     * 
     * @return
     */
    private String isSnackTypeDescNull() {
        if (snackOrTechanTpyeDesc != null) return "snackPage";
        else {
            return ERROR;
        }
    }

    public String getDrinkAndTeaPage() {
        try {
            drinkDesc = foodTypeService.getFoodTypeDescById(FoodTypeEnum.meijiu.getId());
            teaDesc = foodTypeService.getFoodTypeDescById(FoodTypeEnum.tea.getId());
            drinkImageList = foodService.getTypedFoodTypeList(FoodTypeEnum.meijiu.getId(), 6);
            teaImageList = foodService.getTypedFoodTypeList(FoodTypeEnum.tea.getId(), 6);
            drinkList = foodService.getTypedFoodTypeList(FoodTypeEnum.meijiu.getId(), 20);
            teaList = foodService.getTypedFoodTypeList(FoodTypeEnum.tea.getId(), 20);
            return "drinkAndTea";
        } catch (Exception e) {
            e.printStackTrace();
            return ERROR;
        }
    }
}
